<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 6 和 9 组成的最大数字 -->
    <script>
      var maximum69Number = function (num) {
        //转成字符串
        let str = num.toString()
        for (let i = 0; i < str.length; i++) {
          if (str.charAt(i) == 6) {
            //返回一个整数
            return parseInt(str.slice(0, i) + 9 + str.slice(i + 1))
          }
        }
        return num
      }
      console.log(maximum69Number(9669))
    </script>
  </body>
</html>
